<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/8/30 0030
 * Time: 15:22
 */

namespace framework\library;


class Log
{

    public function write($data, $filename, $path = "/")
    {
        $preFileName = $filename . "/" . date('Ymd', time());
        $path = $path . "logs/" . date('Ym', time()) . '/';
        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }
        $ext = '.log';
        $filePath = $path . $preFileName . $ext;
        $content = var_export($data, true);
        $tmp = "\n\n================= " . date('Y-m-d H:i:s') . " ===================\n\n";
        $content = $tmp . $content;

        file_put_contents($filePath, $content);
    }

    public function test()
    {
        return "hello test";
    }

}